home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Tcl / tclWinTime.c < prev   
Encoding:
C/C++ Source or Header  |  1996-06-01  |  2.6 KB  |  128 lines

  1. /* 
  2.  * tclWinTime.c --
  3.  *
  4.  *    Contains Windows specific versions of Tcl functions that
  5.  *    obtain time values from the operating system.
  6.  *
  7.  * Copyright 1995 by Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * SCCS: @(#) tclWinTime.c 1.4 96/04/02 18:49:06
  13.  */
  14.  
  15. #include "tclInt.h"
  16. #include "tclPort.h"
  17.  
  18. /*
  19.  *----------------------------------------------------------------------
  20.  *
  21.  * TclGetSeconds --
  22.  *
  23.  *    This procedure returns the number of seconds from the epoch.
  24.  *    On most Unix systems the epoch is Midnight Jan 1, 1970 GMT.
  25.  *
  26.  * Results:
  27.  *    Number of seconds from the epoch.
  28.  *
  29.  * Side effects:
  30.  *    None.
  31.  *
  32.  *----------------------------------------------------------------------
  33.  */
  34.  
  35. unsigned long
  36. TclGetSeconds()
  37. {
  38.     return (unsigned long) time((time_t *) NULL);
  39. }
  40.  
  41. /*
  42.  *----------------------------------------------------------------------
  43.  *
  44.  * TclGetClicks --
  45.  *
  46.  *    This procedure returns a value that represents the highest
  47.  *    resolution clock available on the system.  There are no
  48.  *    guarantees on what the resolution will be.  In Tcl we will
  49.  *    call this value a "click".  The start time is also system
  50.  *    dependant.
  51.  *
  52.  * Results:
  53.  *    Number of clicks from some start time.
  54.  *
  55.  * Side effects:
  56.  *    None.
  57.  *
  58.  *----------------------------------------------------------------------
  59.  */
  60.  
  61. unsigned long
  62. TclGetClicks()
  63. {
  64.     return GetTickCount();
  65. }
  66.  
  67. /*
  68.  *----------------------------------------------------------------------
  69.  *
  70.  * TclGetTimeZone --
  71.  *
  72.  *    Determines the current timezone.  The method varies wildly
  73.  *    between different Platform implementations, so its hidden in
  74.  *    this function.
  75.  *
  76.  * Results:
  77.  *    Hours east of GMT.
  78.  *
  79.  * Side effects:
  80.  *    None.
  81.  *
  82.  *----------------------------------------------------------------------
  83.  */
  84.  
  85. int
  86. TclGetTimeZone (currentTime)
  87.     unsigned long  currentTime;
  88. {
  89.     static int setTZ = 0;
  90.     int timeZone;
  91.  
  92.     if (!setTZ) {
  93.         tzset();
  94.         setTZ = 1;
  95.     }
  96.     timeZone = _timezone / 60;
  97.  
  98.     return timeZone;
  99. }
  100.  
  101. /*
  102.  *----------------------------------------------------------------------
  103.  *
  104.  * TclGetTime --
  105.  *
  106.  *    Gets the current system time in seconds and microseconds
  107.  *    since the beginning of the epoch: 00:00 UCT, January 1, 1970.
  108.  *
  109.  * Results:
  110.  *    Returns the current time in timePtr.
  111.  *
  112.  * Side effects:
  113.  *    None.
  114.  *
  115.  *----------------------------------------------------------------------
  116.  */
  117.  
  118. void
  119. TclGetTime(timePtr)
  120.     Tcl_Time *timePtr;        /* Location to store time information. */
  121. {
  122.     struct timeb t;
  123.  
  124.     ftime(&t);
  125.     timePtr->sec = t.time;
  126.     timePtr->usec = t.millitm * 1000;
  127. }
  128.